package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Systemdictionary;
import cn.wolfcode.mapper.SystemdictionaryMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ISystemdictionaryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemdictionaryServiceImpl implements ISystemdictionaryService {

    @Autowired
    private SystemdictionaryMapper systemdictionaryMapper;


    @Override
    public void save(Systemdictionary systemdictionary) {
        systemdictionaryMapper.insert(systemdictionary);
    }

    @Override
    public void delete(Long id) {
        systemdictionaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Systemdictionary systemdictionary) {
        systemdictionaryMapper.updateByPrimaryKey(systemdictionary);
    }

    @Override
    public Systemdictionary get(Long id) {
        return systemdictionaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Systemdictionary> listAll() {
        return systemdictionaryMapper.selectAll();
    }

    @Override
    public PageInfo<Systemdictionary> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<Systemdictionary> systemdictionarys = systemdictionaryMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<Systemdictionary>(systemdictionarys);
    }
}
